Mobile devices, such as cellular telephones, commonly incorporate cameras for taking both still images and videos. Typically, the cameras integrated into these mobile devices have limited capabilities, such as a fixed focus or auto-focus, a large depth of field and a limited range of exposure times. In order to enhance photographs taken with such a camera, it is known to build or simulate a depth map of an image. A depth map can be a representation of an image in which different values or colors represent different distances from the camera of the objects in that image. For example, depth maps can be built using colors or shades of gray to represent distances from the camera. The depth map can provide accurate values of distances or values representing relative distances of the objects to the camera without knowing accurately the real distance. Once created, the depth map can be used to perform several types of post-processing on the original image. For example, one can simulate a shallower depth of field in an image by maintaining a sharp image of objects at a given distance from the camera, while blurring objects at other distances. Other examples of processing using a depth map include measuring distances and/or objects in an image and separating objects from the background.